﻿using Domain.Entity;
using Domain.Repository;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repository
{
	public class CFFKRepository : ICFFKRepository
	{
		private readonly MyDbContext myDbContext;

		public CFFKRepository(MyDbContext myDbContext)
        {
			this.myDbContext = myDbContext;
		}
        public async Task<bool> AddCFFKAsync(CFFK cFFK)
		{
			myDbContext.CFFK.Add(cFFK);
			return await myDbContext.SaveChangesAsync() > 0;
		}

		public async Task<bool> DeleteCFFKAsync(int id)
		{
			CFFK cFFK = new CFFK()
			{
				FfkId = id
			};
			myDbContext.CFFK.Remove(cFFK);
			return await myDbContext.SaveChangesAsync() > 0;
		}

		public async Task<List<CFFK>> SelectCFFKAsync()
		{
			return await myDbContext.CFFK.ToListAsync();
		}

		public async Task<bool> UpdateCFFKAsync(CFFK cFFK)
		{
			myDbContext.CFFK.Update(cFFK);
			return await myDbContext.SaveChangesAsync() > 0;
		}
	}
}
